<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>我的收货地址</title>
		<link rel="stylesheet" type="text/css" href="{:_SKIN}/user/css/baojia.css" />
		<!--<link rel="stylesheet" type="text/css" href="css/base.min.css" />
		<link rel="stylesheet" type="text/css" href="css/common.css" />-->
		<link rel="stylesheet" type="text/css" href="{:_SKIN}/user/layui/css/layui.css" />
		
		<style type="text/css">
			.layui-form {
				width: 60%;
			}
			
			.layui-table tr:hover,
			.layui-table[lay-even] tr:nth-child(even) {
				background: #FFFFFF;
			}
			
			.layui-table,
			.layui-table th {
				text-align: center;
			}
			
			.layui-table {
				margin-top: 20px;
			}
			
			.btn {
				background: #ff6600;
				width: 250px;
				margin-top: 10px;
			}
			
			.add {
				width: 90%;
				z-index: 999;
			}
			
			.aqq {
				position: relative;
			}
			
			.aq-1 {
				right: 48px;
			}
			
			.aq-2 {
				left: -97px;
			}
			
			.layui-form-select dl {
				min-width: 100%;
			}
			
			.layui-table td,
			.layui-table th {
				padding: 5px 25px;
			}
		</style>
	</head>

	<body>
		<div class="content">
			<div class="titlebar">
				<div class="titlebar-name">我的收货地址</div>
			</div>

			<form class="layui-form" id="bd1">
				<table class="layui-table" lay-even lay-skin="nob">
					<colgroup>
						<col width="150">
						<col width="200">
						<col>
					</colgroup>
					<tbody>
						<tr style="text-align: left;">
							<td colspan="4"><b>新增收货地址：</b></td>
						</tr>
						<tr>
							<td colspan="2">
								<div class="layui-form-item">
									<label class="layui-form-label">所在地区：</label>
									<div class="layui-input-block add">
										<select name="city" lay-verify="">
											<option value="">请选择城市</option>
											<option value="010">北京</option>
											<option value="021">上海</option>
											<option value="0571">杭州</option>
										</select>
									</div>
								</div>
							</td>

							<td>
								<div class="layui-form-item aqq aq-1">
									<div class="layui-input-block add">
										<select name="city" lay-verify="">
											<option value="">请选择城市</option>
											<option value="010">北京</option>
											<option value="021">上海</option>
											<option value="0571">杭州</option>
										</select>
									</div>
								</div>
							</td>
							<td>
								<div class="layui-form-item aqq aq-2">
									<div class="layui-input-block add">
										<select name="city" lay-verify="">
											<option value="">请选择城市</option>
											<option value="010">北京</option>
											<option value="021">上海</option>
											<option value="0571">杭州</option>
										</select>
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td colspan="4">
								<div class="layui-form-item">
									<label class="layui-form-label">街道地址：</label>
									<div class="layui-input-block">
										<input type="text" name="address" required lay-verify="required" placeholder="例如街道名称，门牌号码，楼层和房间号等信息" autocomplete="off" class="layui-input">
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td colspan="4">
								<div class="layui-form-item">
									<label class="layui-form-label">邮政编码：</label>
									<div class="layui-input-block">
										<input type="text" name="Email" required lay-verify="required" placeholder="不清楚邮政编码，请填写000000" autocomplete="off" class="layui-input">
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td colspan="4">
								<div class="layui-form-item">
									<label class="layui-form-label">收货人：</label>
									<div class="layui-input-block">
										<input type="text" name="name" required lay-verify="required" placeholder="请输入收货人姓名" autocomplete="off" class="layui-input">
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td colspan="4">
								<div class="layui-form-item">
									<label class="layui-form-label">电话号码：</label>
									<div class="layui-input-block">
										<input type="text" name="tel" required lay-verify="required" placeholder="请输入您的电话号码" autocomplete="off" class="layui-input ">
									</div>
								</div>
							</td>
						</tr>
						<tr style="text-align: right;">
							<td colspan="4">
								<input type="checkbox" />
								<span>设为默认地址</span>
							</td>
						</tr>
						<tr>
							<td colspan="4">
								<div class="layui-form-item">
									<div class="layui-input-block">

										<button class="layui-btn btn layui-btn-danger" onclick="but();" lay-submit lay-filter="formDemo">立即保存</button>

									</div>
								</div>
							</td>
						</tr>
					</tbody>
				</table>
			</form>
			<div class="list-table">

				<h2>已保存了
					<span class="red ">{:count($info)}</span>



					条地址，还能保存 
					<span class="red">
						 {php}

						 echo 20-count($info);

						 {/php}

					</span> 

					条地址

				</h2>



				<table class="layui-table">
					<colgroup>
						<col width="150">
						<col width="200">
						<col>
					</colgroup>
					<thead>
						<tr>
							<th>收货人</th>
							<!-- <th>所在地区</th> -->
							<th>街道地址</th>
							<th>邮编</th>
							<th>电话/手机</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						{volist name="info" id="vo"}
						<tr>

							<td>{$vo.name}</td>
							<td>{$vo.address}</td>
							<td>{$vo.sb}</td>
							<td>{$vo.tel}</td>
							<!-- <td>{$vo.Name}</td>
							<td>{$vo.Area}</td>
							<td>{$vo.AddressDis}</td>
							<td>{$vo.Mobile}</td> -->
							<td>
								<a href="{:url('gpssave',array('id'=>$vo['id']))}" style="color: #1E9FFF;">修改</a>
								<a class="s_delete" style="color: red;"  data-id="{$vo.id}">删除</a>
							</td>
						</tr>
						{/volist}
					</tbody>
				</table>
			</div>
		</div>
		{:jq()}
		{:layui()}
		<script type="text/javascript">
		function but(){

				var data=$("#bd1").serialize();


			 if (!data.address || !data.name || data.tel.length!=11) {


		        alert('请输入正确的信息');
		        return false;
   			 }
			$.post("{:url('user/buyers/gps')}",data,function(res){
				//console.log(res);
				if(res.code==200){

					alert('添加成功');
					window.location.href="{:url('indexs')}";
				}else{

					alert(res.msg);
				}


			});

		}




		 $(".s_delete").click(function () {

				var id = $(this).data('id');



				var r=confirm("确定要删除吗？删除后不能恢复");
					if(r==true){

							$.post("{:url('user/buyers/del')}", {id:id}, function (res) {

								
								if(res.code==200){
									
									alert('删除成功');
									window.location.reload();

								}else{

									alert(res.msg);
								}
							
						});




					}

			

		


	});







			

	


		</script>
	</body>

</html>